<?php
	include("User/config.php");
	session_start();	
  
	if($_SERVER["REQUEST_METHOD"]=="POST")
	{
		$username = addslashes($_POST['name']);
		$password = md5(addslashes($_POST['pass']));
		
		$sql ="SELECT * FROM Customer WHERE email='$username' AND password='$password'";
		$result = mysql_query($sql);
		$count = mysql_num_rows($result);		
		if($count==1)
		{
			session_register("myusername");
			$_SESSION['login_user'] = $username;
			$_SESSION['logged_in'] = true;
			header("location:User/index2.php");
		}
		else
			$error="Your email or password is invalid";
	}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Final Project</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="This is a e-commerce website for a final project in Web Server Programming 2012">
    <meta name="author" content="Elliot Wasser">
    <!-- Le styles -->
    <link href="inc/bootstrap/css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
    	body{
    		padding-top: 60px;
    		padding-bottom: 40px;
    	}
    </style>
    <link href="inc/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
  </head>
<body>	 
	 <div class="navbar navbar-inverse navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          <a class="brand" href="">Web Server Final 2012</a>
          <div class="nav-collapse">
            <ul class="nav">
              <li><a href="User/index.php">Home</a></li>
              <li><a href="User/shop.php">Shop</a></li>
              <li><a href="User/contact.php">Information</a></li>              
              <form class="navbar-form pull-right" action="" method="post">   			  	  
   			      <input type="text" name="name" class="span2" placeholder="E-mail">   				  
   			      <input type="password" name="pass" class="span2" placeholder="password">   				  
   				  <button type="submit" class="btn">Log in</button>
  			  </form>
  			  <li><a href="User/twitter_serverside.php">Twitter</a></li>
			  <li><a href="create.php">Sign Up</a></li>
            </ul>
          </div><!--/.nav-collapse -->
        </div>
      </div>
    </div>
    <div class="container">                       
      <!-- Main hero unit for a primary marketing message or call to action -->
      <div class="hero-unit">
        <h1>Elliot's E-Commerce Website</h1>
        <p>In this site you will be able to buy items online, see our employees, and go to our facebook page.</p>
        <p><a class="btn btn-primary btn-large">Learn more &raquo;</a></p>
      </div>
      <hr>
      <footer>
        <p>&copy; Company 2012</p>
      </footer>
    </div> <!-- /container -->
    <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="inc/bootstrap/js/jquery.js"></script>
    <script src="inc/bootstrap/js/bootstrap-min.js"></script>
  </body>
</html>
